1. Field of the Invention
The present invention relates to gateways used in Internetworking Technologies, and more specifically to a method and apparatus for forwarding packets in a gateway performing network address translation (NAT).
2. Related Art
Gateways are often used to enable users at remote locations (e.g., at homes) to access different target systems (e.g., a computer system on a local area network). A gateway provides the connectivity between remote systems (e.g., personal computers) at remote locations with the target systems of interest to enable different network applications.
One of the common tasks performed by a gateway is forwarding (or routing) of packets. In a typical situation, the gateway receives a packet on one port (e.g., from a remote system) and forwards the packet on another port (e.g., to a target system). Forwarding usually entails a route lookup operation in which a forwarding table is examined to determine the specific port on which to forward a received packet. The forwarding task generally provides the basic building block to inter-connect a large number of systems using potentially many gateways.
Another task performed by some of the gateways is network address translation (NAT). NAT generally refers to substitution of an address (“original address”) in a received packet with a new address. The substitution generally enables a system (either remote system of target system) to be addressed consistent with the local addressing approach at both ends of a communication path.
For example, a remote system may be addressed by a local address at a remote location and by an external address by a target system. A gateway performs the necessary substitutions (i.e., from local address to external address when packets are transmitted from the remote system to target system, and from external address to local address when transmitted in the other direction) to allow communication between the two systems using different addresses.
Such substitutions also require a lookup operation, in which a NAT table is examined to map the original address to the new address. For further details of many types of NAT implementations, the reader is referred to request for comment (RFC) 1661, available from www.ietf.org, and is incorporated in its entirety herewith.
A prior gateway may employ separate searches associated with the forwarding and NAT tasks. Multiple searches generally consume more time. The additional time requirement may impede the throughput performance of a gateway, and may thus be undesirable. What is therefore needed is a method and apparatus which enables a gateway to forward packets quickly while supporting NAT.